<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>lesson 15</title>
    <script src="https://unpkg.com/vue@next"></script>
</head>

<body>
    <div id="root">
        <!-- 动态传参 v-bind  -->
        <test :content="num" />
        <test1 :num1="number" />
    </div>

    <script>
        const app = Vue.createApp({

            data() {
                return {
                    num: () => { 
                        console.log(123) 
                    },
                    number: 1234
                }
            }
        });

        app.component('test1', {
            props: {
                num1: {
                    type: Number,
                    validator: function (value) {
                        return value < 1000;
                    },
                    default: function () {
                        return 456;
                    }
                }
            },
            template: `<div>{{ num1 }}</div>`
        })

        // String Boolean Number Array Object Function Symbol(占位符)
        app.component('test', {
            // 向组件内传值
            props: {
                content: Function
            },
            methods: {
                handleClick() {
                    alert(456);
                    // 此处调用需要加上括号 才算调用函数传参
                    this.content();
                }
            },
            // typeof 打印出内容的类型
            template: `<div @click="this.handleClick">{{ typeof content }}</div>`
        })

        const vm = app.mount('#root')
    </script>
</body>

</html>